# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=nginx-mod-srcache
pkgver=0.33
pkgrel=2

_modname="${pkgname#nginx-mod-}"

pkgdesc='Nginx module for transparent subrequest-based caching layout for arbitrary locations'
arch=('loong64' 'x86_64')
depends=('nginx')
makedepends=('nginx-src')
url="https://github.com/openresty/srcache-nginx-module"
license=('BSD')

source=(
	https://github.com/openresty/$_modname-nginx-module/archive/v$pkgver/$_modname-$pkgver.tar.gz
)
validpgpkeys=(B0F4253373F8F6F510D42178520A9993A1C052F8) # Maxim Dounin <mdounin@mdounin.ru>
sha256sums=('1ffd3e244a52bc2ad31661b038fa20fab3145dea506d97f53c2ac80b55eb38d3')

build() {
	cp -r /usr/src/nginx .

	cd "$srcdir"/nginx
	./configure --with-compat --add-dynamic-module=../$_modname-nginx-module-$pkgver
	make modules
}

package() {
	cd "$srcdir"/nginx/objs
	for mod in *.so; do
		install -Dm755 $mod "$pkgdir"/usr/lib/nginx/modules/$mod
	done

	install -Dm644 "$srcdir"/$_modname-nginx-module-$pkgver/README.markdown \
	               "$pkgdir"/usr/share/licenses/$pkgname/README.markdown
}
